package com.ayu.scalalearn.chapter06

/**
  * @Author 徐林玉
  * @Description Test04ConstructorParams
  * @Date 2022/7/28 15:07
  * @Version 1.0
  */
object Test04ConstructorParams {


  def main(args: Array[String]): Unit = {

    val stu1 = new Student3("ayu", 18);

    val stu2 = new Student4()

    stu2.age = 19
    stu2.name = "yy"

    println(stu1.name, stu1.age)

    println(stu2.name, stu2.age)
  }

}


//这样子相当于直接调用了主构造器，初始化了 name，age字段
class Student3(var name: String, var age: Int) {


}

//等价于
class Student4() {

  var name: String = _

  var age: Int = _
}
